package com.martin.fastframe.ui.main

import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.martin.fastframe.R
import com.martin.fastframe.databinding.ActivityMainBinding
import com.martin.lib_base.base.BaseActivity
import com.martin.lib_base.impl.EmptyViewModel
import com.martin.lib_base.interfaces.IOnItemClickListener
import com.martin.lib_base.ktx.refresh
import com.martin.lib_base.ktx.addOnItemClickListener
import com.xuexiang.xui.utils.StatusBarUtils
import dev.utils.app.ViewUtils

class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {

    override fun getViewModelClass() = MainViewModel::class.java

    override fun layoutId() = R.layout.activity_main

    override fun initOnCreate(savedInstanceState: Bundle?) {
        binding.viewModel = viewModel
        //刷新数据
        binding.rv.refresh(viewModel.items)

        binding.rv.addOnItemClickListener(object : IOnItemClickListener {
            override fun onItemClick(position: Int, type: Int) {
                viewModel.onItemClick(this@MainActivity, position)
            }
        })

        lifecycleScope
    }
}